﻿using System;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;

namespace CIB.AutoTitle.ServerCode.Receivers.CustomListReceiver
{
    /// <summary>
    /// List Item Events
    /// </summary>
    public class CustomListReceiver : SPItemEventReceiver
    {
        /// <summary>
        /// An item was added.
        /// </summary>
        public override void ItemAdded(SPItemEventProperties properties)
        {
            base.ItemAdded(properties);

            try
            {
                var ListItem = properties.ListItem;
                var UnMaskTheFields = new FieldMask(ListItem);
                UnMaskTheFields.Update();

            }
            catch (Exception)
            {
                // Unexpected error in receiver
            }

        }

        /// <summary>
        /// An item was updated.
        /// </summary>
        public override void ItemUpdated(SPItemEventProperties properties)
        {
            base.ItemUpdated(properties);

            try
            {
                var ListItem = properties.ListItem;
                var UnMaskTheFields = new FieldMask(ListItem);
                UnMaskTheFields.Update();            

            }
            catch (Exception)
            {
                 //Unexpected error in receiver
            }


        }


    }
}